home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / NetWarmer / source / MainWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-22  |  3.3 KB  |  148 lines  |  [TEXT/KAHL]

  1. /* MainWindow.c */
  2. /* Created 3/13/4 1:08 PM by AppMaker */
  3.  
  4.  
  5. #include "Globals.h"
  6. #include "ResourceDefs.h"
  7. #include "Scrolling.h"
  8. #include "WindowAids.h"
  9. #include "Miscellany.h"
  10.  
  11. #include "MainWindow.h"
  12.  
  13.  
  14. #define NIL            0L
  15.  
  16. /*----------*/
  17. void OpenMainWindow (fName, vRefNum, fRefNum)
  18. Str255        fName;
  19. short        vRefNum;
  20. short        fRefNum;
  21. {
  22.     WindowPtr        newWindow;
  23.     Rect            bounds;
  24.  
  25.     newWindow = GetNewWindow (MainWindowID, nil, (WindowPtr) -1L);
  26.     //SetWTitle (newWindow, fName);
  27.     SetPort (newWindow);
  28.     SetNewInfo (newWindow);
  29.     cur->vScroll = nil;
  30.     cur->hScroll = nil;
  31.     cur->PasswordHandle = GetNewControl (128, newWindow);
  32.     SetRect (&bounds, 44, 224, 200, 240);
  33.     cur->Field2Handle = TENew (&bounds, &bounds);
  34.     TEAutoView (true, cur->Field2Handle);
  35.     cur->AllowRemoteWarmHandle = GetNewControl (132, newWindow);
  36.     cur->Slider10Handle = GetNewControl (133, newWindow);    
  37.         cur->text = cur->Field2Handle;
  38.     cur->fileNum    = fRefNum;
  39.     cur->volNum        = vRefNum;
  40.     cur->dirty        = false;
  41.     cur->filename    = NewString (fName);
  42.     cur->windowKind = WMainWindow;
  43.  
  44.     ShowWindow (newWindow);
  45.  
  46. } /*OpenMainWindow*/
  47.  
  48. /*----------*/
  49. void CloseMainWindow ()
  50. {
  51.     TEDispose (cur->Field2Handle);
  52.         
  53.     DisposHandle ((Handle) cur->filename);
  54.     DiscardInfo (curWindow);
  55. } /*CloseMainWindow*/
  56.  
  57. /*----------*/
  58. void MouseInMainWindow (where, modifiers)
  59. Point        where;
  60. short        modifiers;
  61. {
  62.     Rect            bounds;
  63.  
  64.     if (PtInRect (where, &(**(cur->Field2Handle)).viewRect)) {
  65.         if (cur->text != nil) {
  66.             TEDeactivate (cur->text);
  67.         }
  68.         cur->text = cur->Field2Handle;
  69.         TEActivate (cur->text);
  70.         TEClick (where, false, cur->text);
  71.     }
  72.     } /*MouseInMainWindow*/
  73.  
  74. /*----------*/
  75. void TypeInMainWindow   (ch)
  76. char        ch;
  77. {
  78.     if (cur->text == nil) {
  79.         SysBeep (1);
  80.     } else {
  81.         TEKey (ch, cur->text);
  82.     }
  83. } /*TypeInMainWindow*/
  84.  
  85. /*----------*/
  86. void UpdateMainWindow ()
  87. {
  88.     Rect            bounds;
  89.  
  90.     TEUpdate (&thePort->portRect, cur->Field2Handle);
  91.     SetRect (&bounds, 40, 76, 89, 126);
  92.     DrawPictureID (129, bounds);
  93.     SetRect (&bounds, 40, 128, 88, 160);
  94.     TextIDBox (128, bounds);
  95.     SetRect (&bounds, 128, 68, 192, 164);
  96.     FrameRect (&bounds);
  97.     SetRect (&bounds, 28, 68, 96, 164);
  98.     FrameRect (&bounds);
  99.     SetRect (&bounds, 12, 12, 168, 40);
  100.     DrawPictureID (133, bounds);
  101.     SetRect (&bounds, 96, 40, 198, 54);
  102.     DrawPictureID (132, bounds);
  103.     SetRect (&bounds, 156, 80, 187, 138);
  104.     DrawPictureID (130, bounds);
  105.     } /*UpdateMainWindow*/
  106.  
  107. /*----------*/
  108. void ActivateMainWindow (activate)
  109. Boolean        activate;
  110. {
  111.     HiliteScroll (cur->Slider10Handle, activate);
  112.     } /*ActivateMainWindow*/
  113.  
  114. /*----------*/
  115. void ResizeMainWindow ()
  116. {
  117.     /* application-specific code to resize items in window */
  118. } /*ResizeMainWindow*/
  119.  
  120. /*----------*/
  121. pascal void ScrollMainWindow (newValue, oldValue)
  122. short        newValue;
  123. short        oldValue;
  124. {
  125.     /* application-specific code to scroll window */
  126. } /*ScrollMainWindow*/
  127.  
  128. /*----------*/
  129. void ControlMainWindow    (whichControl, whichPart, where)
  130. ControlHandle    whichControl;
  131. short             whichPart;
  132. Point            where;
  133. {
  134.     Rect            bounds;
  135.  
  136.     if (whichControl == cur->PasswordHandle) {
  137.         TrackCheck (cur->PasswordHandle, where, &cur->PasswordChecked);
  138.     }
  139.     if (whichControl == cur->AllowRemoteWarmHandle) {
  140.         TrackCheck (cur->AllowRemoteWarmHandle, where, &cur->AllowRemoteWarmChecked);
  141.     }
  142.     if (whichControl == cur->Slider10Handle) {
  143.         TrackScroll (cur->Slider10Handle, whichPart, where, nil);
  144.     }
  145.     } /*ControlMainWindow*/
  146.  
  147. /* MainWindow */
  148.